from redis import StrictRedis

class Config(object):
    """项目配置"""
    # DEBUG = True
    # base64.b64encode(os.urandom(64))
    SECRET_KEY = '1Y+NjBdatmI8+ezk8AmUYYL47b3C1HM76KYaBUfXI4hE11ua/+X4o1GrEhEfqy5o'
    # 数据库配置
    SQLALCHEMY_DATABASE_URI = 'mysql://root:123456@localhost:3306/information'
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 在请求结束时，如果指定此配置为True,那么SQLAlchemy会自动执行db.session.commit()
    SQLALCHEMY_COMMIT_ON_TEARDOWN = True

    # Redis配置
    REDIS_HOST = '127.0.0.1'
    REDIS_PORT = 6379

    # session保存设置
    SESSION_TYPE = 'redis'
    # 开启session签名
    SESSION_USE_SIGNER = True
    # 设置需要过期
    SESSION_PERMANENT = False
    # 指定session保存的redis
    SESSION_REDIS = StrictRedis(host=REDIS_HOST,port=REDIS_PORT)
    # 设置过期时间
    PERMANENT_SESSION_LIFETIME = 60*60*24*2
    # 设置日志等级
    LOGGING_LEVEL = 'DEBUG'


class DevelopmentConfig(Config):
    """开发环境下配置"""
    DEBUG = True


class ProductionConfig(Config):
    """生产环境下配置"""
    DEBUG = False
    # 数据库配置
    # SQLALCHEMY_DATABASE_URI = 'mysql://root:123456@localhost:3306/information'
    LOGGING_LEVEL = 'WARNING'


class TestingConfig(Config):
    """单元测试下配置"""
    DEBUG = True
    TESTING = True

config = {
    "development":DevelopmentConfig,
    "production":ProductionConfig,
    'testing':TestingConfig
}